{
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "000729 燕京啤酒\n",
    "600132 重庆啤酒\n",
    "002461  珠江啤酒\n",
    "600600 青岛啤酒\n",
    "600573 惠泉啤酒\n",
    "作业要求细则:\n",
    "1. 选取制造业细分领域规模相似的5家上市公司,作为分析对象.\n",
    "2. 要有公司基本面信息.\n",
    "3. 从主要财务指标的22项相当中选取若干项进行挖掘分析.可以选取多种组合.需要进行5家公司的同比,得出行业整体的结论.与各公司与整体的差异性结论.          加分项:可以统计5家公司均值,然后与均值进行比对分析.\n",
    "4. 对利润表,资产负债表,现金流量表要有分析.\n",
    "5. 加分项:结合股价进行分析.\n",
    "6. 导出部分EXCEL文件作为报告附件.\n",
    "\n",
    "以上所有分析,需要有数据采集-数据清洗-数据可视化-数据分析报告的所有步骤.\n",
    "报告可以在word或者excel中完成.\n",
    "加分项:应用课堂学到的所有可视化技术:折线图,柱状图(3维合1,既有同比也有环比),饼图.辅助线,文字,箭头等.\n",
    "预算不超100"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import requests\n",
    "from pprint import pprint\n",
    "def get_data(code):\n",
    "    web = 'http://www.cninfo.com.cn/'\n",
    "    path1 = 'data20/companyOverview/getCompanyIntroduction?scode={}'.format(code)\n",
    "    url= web + path1\n",
    "    r = requests.get(url)\n",
    "    s = r.json()\n",
    "    df = pd.DataFrame([s['data']['records'][0]['basicInformation'][0]])\n",
    "\n",
    "    path2 = 'data20/financialData/getIncomeStatement?scode={}&sign=1'.format(code)\n",
    "    url2= web + path2\n",
    "    r2 = requests.get(url2)\n",
    "    s2 = r2.json()\n",
    "    df2 = pd.DataFrame(s2['data']['records'][0]['year'])\n",
    "    df2 = df2.iloc[:,[4,3,2,1,0,5]]\n",
    "\n",
    "    path3 = 'data/cube/dailyLine?stockCode={}'.format(code)\n",
    "    url3= web + path3\n",
    "    r3 = requests.get(url3)\n",
    "    s3 = r3.json()\n",
    "    columns = s3['valuetype']\n",
    "    data = s3['line']\n",
    "    df3 = pd.DataFrame(data,columns=columns)\n",
    "\n",
    "    path4 = 'data20/stockholderCapital/getTopTenStockholders?scode={}'.format(code)\n",
    "    url4= web + path4\n",
    "    r4 = requests.get(url4)\n",
    "    s4 = r4.json()\n",
    "    df4 = pd.DataFrame(s4['data']['records'])\n",
    "    df4.columns = ['持股比例','公告日期','持股数量(万股)',\n",
    "               '股份性质','编号','股东名称','持股比例变动情况']\n",
    "    df4 = df4.iloc[:,[4,0,1,2,3,5,6]]\n",
    "    return df, df2, df3, df4"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "outputs": [],
   "source": [
    "d1, d2, d3, d4 = get_data('600573')"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "outputs": [
    {
     "data": {
      "text/plain": "               TIME   OPEN  CLOSE   HIGH    LOW       MONEY        VOL  \\\n0     1468166400000  13.80  13.55  13.85  13.53  57687421.0  4219918.0   \n1     1468252800000  13.54  13.68  13.74  13.39  40679569.0  2999280.0   \n2     1468339200000  13.79  13.80  13.95  13.63  76356175.0  5536925.0   \n3     1468425600000  13.84  13.95  14.00  13.74  70178540.0  5050405.0   \n4     1468512000000  13.99  13.89  14.04  13.81  66072578.0  4745990.0   \n...             ...    ...    ...    ...    ...         ...        ...   \n1212  1625414400000  10.00  10.12  10.19   9.90  51337933.0  5089261.0   \n1213  1625500800000  10.05  10.12  10.15   9.84  66508795.0  6664176.0   \n1214  1625587200000  10.06  10.10  10.31   9.99  64377373.0  6334233.0   \n1215  1625673600000  10.02   9.86  10.05   9.85  62800287.0  6330132.0   \n1216  1625760000000   9.77   9.79   9.82   9.41  69654030.0  7241775.0   \n\n      KZHANGDIEFU  KZHANGDIE  \n0          -1.812      -0.25  \n1           0.959       0.13  \n2           0.877       0.12  \n3           1.087       0.15  \n4          -0.430      -0.06  \n...           ...        ...  \n1212        0.697       0.07  \n1213        0.000       0.00  \n1214       -0.198      -0.02  \n1215       -2.376      -0.24  \n1216       -0.710      -0.07  \n\n[1217 rows x 9 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>TIME</th>\n      <th>OPEN</th>\n      <th>CLOSE</th>\n      <th>HIGH</th>\n      <th>LOW</th>\n      <th>MONEY</th>\n      <th>VOL</th>\n      <th>KZHANGDIEFU</th>\n      <th>KZHANGDIE</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>1468166400000</td>\n      <td>13.80</td>\n      <td>13.55</td>\n      <td>13.85</td>\n      <td>13.53</td>\n      <td>57687421.0</td>\n      <td>4219918.0</td>\n      <td>-1.812</td>\n      <td>-0.25</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>1468252800000</td>\n      <td>13.54</td>\n      <td>13.68</td>\n      <td>13.74</td>\n      <td>13.39</td>\n      <td>40679569.0</td>\n      <td>2999280.0</td>\n      <td>0.959</td>\n      <td>0.13</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>1468339200000</td>\n      <td>13.79</td>\n      <td>13.80</td>\n      <td>13.95</td>\n      <td>13.63</td>\n      <td>76356175.0</td>\n      <td>5536925.0</td>\n      <td>0.877</td>\n      <td>0.12</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>1468425600000</td>\n      <td>13.84</td>\n      <td>13.95</td>\n      <td>14.00</td>\n      <td>13.74</td>\n      <td>70178540.0</td>\n      <td>5050405.0</td>\n      <td>1.087</td>\n      <td>0.15</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>1468512000000</td>\n      <td>13.99</td>\n      <td>13.89</td>\n      <td>14.04</td>\n      <td>13.81</td>\n      <td>66072578.0</td>\n      <td>4745990.0</td>\n      <td>-0.430</td>\n      <td>-0.06</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>1212</th>\n      <td>1625414400000</td>\n      <td>10.00</td>\n      <td>10.12</td>\n      <td>10.19</td>\n      <td>9.90</td>\n      <td>51337933.0</td>\n      <td>5089261.0</td>\n      <td>0.697</td>\n      <td>0.07</td>\n    </tr>\n    <tr>\n      <th>1213</th>\n      <td>1625500800000</td>\n      <td>10.05</td>\n      <td>10.12</td>\n      <td>10.15</td>\n      <td>9.84</td>\n      <td>66508795.0</td>\n      <td>6664176.0</td>\n      <td>0.000</td>\n      <td>0.00</td>\n    </tr>\n    <tr>\n      <th>1214</th>\n      <td>1625587200000</td>\n      <td>10.06</td>\n      <td>10.10</td>\n      <td>10.31</td>\n      <td>9.99</td>\n      <td>64377373.0</td>\n      <td>6334233.0</td>\n      <td>-0.198</td>\n      <td>-0.02</td>\n    </tr>\n    <tr>\n      <th>1215</th>\n      <td>1625673600000</td>\n      <td>10.02</td>\n      <td>9.86</td>\n      <td>10.05</td>\n      <td>9.85</td>\n      <td>62800287.0</td>\n      <td>6330132.0</td>\n      <td>-2.376</td>\n      <td>-0.24</td>\n    </tr>\n    <tr>\n      <th>1216</th>\n      <td>1625760000000</td>\n      <td>9.77</td>\n      <td>9.79</td>\n      <td>9.82</td>\n      <td>9.41</td>\n      <td>69654030.0</td>\n      <td>7241775.0</td>\n      <td>-0.710</td>\n      <td>-0.07</td>\n    </tr>\n  </tbody>\n</table>\n<p>1217 rows × 9 columns</p>\n</div>"
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d3"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}